package sdedit.serializer;

import com.google.inject.Inject;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.IGrammarAccess;
import org.eclipse.xtext.RuleCall;
import org.eclipse.xtext.nodemodel.INode;
import org.eclipse.xtext.serializer.analysis.GrammarAlias.AbstractElementAlias;
import org.eclipse.xtext.serializer.analysis.GrammarAlias.AlternativeAlias;
import org.eclipse.xtext.serializer.analysis.GrammarAlias.GroupAlias;
import org.eclipse.xtext.serializer.analysis.GrammarAlias.TokenAlias;
import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynNavigable;
import org.eclipse.xtext.serializer.analysis.ISyntacticSequencerPDAProvider.ISynTransition;
import org.eclipse.xtext.serializer.sequencer.AbstractSyntacticSequencer;
import sdedit.services.SDELangGrammarAccess;

@SuppressWarnings("all")
public class SDELangSyntacticSequencer extends AbstractSyntacticSequencer {

	protected SDELangGrammarAccess grammarAccess;
	protected AbstractElementAlias match_SDEditAlt_ElseKeyword_4_0_q;
	protected AbstractElementAlias match_SDEditObj___LeftSquareBracketKeyword_3_0___AKeyword_3_1_0_or_PKeyword_3_1_1_or_RKeyword_3_1_2_or_XKeyword_3_1_3___RightSquareBracketKeyword_3_2__q;
	
	@Inject
	protected void init(IGrammarAccess access) {
		grammarAccess = (SDELangGrammarAccess) access;
		match_SDEditAlt_ElseKeyword_4_0_q = new TokenAlias(false, true, grammarAccess.getSDEditAltAccess().getElseKeyword_4_0());
		match_SDEditObj___LeftSquareBracketKeyword_3_0___AKeyword_3_1_0_or_PKeyword_3_1_1_or_RKeyword_3_1_2_or_XKeyword_3_1_3___RightSquareBracketKeyword_3_2__q = new GroupAlias(false, true, new TokenAlias(false, false, grammarAccess.getSDEditObjAccess().getLeftSquareBracketKeyword_3_0()), new AlternativeAlias(false, false, new TokenAlias(false, false, grammarAccess.getSDEditObjAccess().getAKeyword_3_1_0()), new TokenAlias(false, false, grammarAccess.getSDEditObjAccess().getPKeyword_3_1_1()), new TokenAlias(false, false, grammarAccess.getSDEditObjAccess().getRKeyword_3_1_2()), new TokenAlias(false, false, grammarAccess.getSDEditObjAccess().getXKeyword_3_1_3())), new TokenAlias(false, false, grammarAccess.getSDEditObjAccess().getRightSquareBracketKeyword_3_2()));
	}
	
	@Override
	protected String getUnassignedRuleCallToken(EObject semanticObject, RuleCall ruleCall, INode node) {
		return "";
	}
	
	
	@Override
	protected void emitUnassignedTokens(EObject semanticObject, ISynTransition transition, INode fromNode, INode toNode) {
		if (transition.getAmbiguousSyntaxes().isEmpty()) return;
		List<INode> transitionNodes = collectNodes(fromNode, toNode);
		for (AbstractElementAlias syntax : transition.getAmbiguousSyntaxes()) {
			List<INode> syntaxNodes = getNodesFor(transitionNodes, syntax);
			if(match_SDEditAlt_ElseKeyword_4_0_q.equals(syntax))
				emit_SDEditAlt_ElseKeyword_4_0_q(semanticObject, getLastNavigableState(), syntaxNodes);
			else if(match_SDEditObj___LeftSquareBracketKeyword_3_0___AKeyword_3_1_0_or_PKeyword_3_1_1_or_RKeyword_3_1_2_or_XKeyword_3_1_3___RightSquareBracketKeyword_3_2__q.equals(syntax))
				emit_SDEditObj___LeftSquareBracketKeyword_3_0___AKeyword_3_1_0_or_PKeyword_3_1_1_or_RKeyword_3_1_2_or_XKeyword_3_1_3___RightSquareBracketKeyword_3_2__q(semanticObject, getLastNavigableState(), syntaxNodes);
			else acceptNodes(getLastNavigableState(), syntaxNodes);
		}
	}

	/**
	 * Syntax:
	 *     '--[else]'?
	 */
	protected void emit_SDEditAlt_ElseKeyword_4_0_q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
	/**
	 * Syntax:
	 *     ('[' ('x' | 'p' | 'r' | 'a') ']')?
	 */
	protected void emit_SDEditObj___LeftSquareBracketKeyword_3_0___AKeyword_3_1_0_or_PKeyword_3_1_1_or_RKeyword_3_1_2_or_XKeyword_3_1_3___RightSquareBracketKeyword_3_2__q(EObject semanticObject, ISynNavigable transition, List<INode> nodes) {
		acceptNodes(transition, nodes);
	}
	
}
